package com.Home
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	import com.UI.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	public class PanelHomeCapture extends JPanel
	{
		//members define
		private var labelName:JLabel;
		private var panelHead:JPanel;
		public function PanelHomeCapture()
		{
			//component creation
			setSize(new IntDimension(120, 85));
			setPreferredSize(new IntDimension(120, 85));
			var layout0:FlowWrapLayout = new FlowWrapLayout();
			layout0.setPreferWidth(200);
			layout0.setAlignment(AsWingConstants.CENTER);
			layout0.setHgap(0);
			layout0.setVgap(0);
			layout0.setMargin(false);
			setLayout(layout0);
			
			labelName = new JLabel();
			labelName.setLocation(new IntPoint(0, 0));
			labelName.setSize(new IntDimension(120, 16));
			labelName.setPreferredSize(new IntDimension(120, 16));
			labelName.setText("label");
			
			panelHead = new JPanel();
			panelHead.setLocation(new IntPoint(25, 16));
			panelHead.setSize(new IntDimension(69, 69));
			panelHead.setPreferredSize(new IntDimension(69, 69));
			
			//component layoution
			append(labelName);
			append(panelHead);
			
			//--------------------
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);

			setClipMasked(false);
			panelHead.setClipMasked(false);
			
			labelName.setForeground(ASColor.WHITE);
			labelName.setFont(font);
			labelName.setTextFilters(new Array(filter));
			
			panelHead.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
			panelHead.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
			panelHead.addEventListener(ClickCountEvent.CLICK_COUNT, onItemClickCount);  
			panelHead.buttonMode = true;
		}
		private var _filterArray:Array = new Array(new GlowFilter(0xffff00, 1, 20, 20));
		private function onRollOver(event:MouseEvent):void
		{
			event.target.filters = _filterArray;
		}
		
		private function onRollOut(event:MouseEvent):void
		{
			event.target.filters = null;
		}
		private function onItemClickCount(event:ClickCountEvent):void
		{   
			if(event.getCount() == 1)
			{   
				if(_building != null && _building.userObject.m_nCaptureCharId != null && _building.userObject.m_nCaptureCharId != 0)
				{
					FrameClickHomeCapture.show(this,width/2, height/2);
					return;
				}
			}   
			FrameClickHomeCapture.hide();
		}
		public var _building:ObjectHomeBuilding = null;
		public function set item(building:ObjectHomeBuilding):void
		{
			_building = building;
			labelName.setText("");
			panelHead.setBackgroundDecorator(null);
			
			if(building == null || building.userObject.m_nState != Const.HOME_BUILDING_STATE_CAPTURE)
				return;
			labelName.setText(building.userObject.m_szCaptureCharName);//+' Lv.'+building.userObject.m_nCaptureLevel);
			panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		}
		public function get item():ObjectHomeBuilding
		{
			return _building;
		}
	}
}

import com.*;
import com.Home.*;
import com.Engine.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;

/**
 * MyPaneClickItem
 */
class FrameClickHomeCapture extends JFrame{
	
	//members define
	private var btn_home_deliver:JButton;
	private var btn_home_resist:JButton;
	private var btn_close:JButton;
	
	/**
	 * MyPaneClickItem Constructor
	 */
	public function FrameClickHomeCapture(){
		
		setResizable(false);
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(198, 0));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		this.getTitleBar().setCloseButton(btn_close);
		this.setClipMasked(false);
		getContentPane().setClipMasked(false);
		getTitleBar().getFrame().setClipMasked(false);
		btn_close.setClipMasked(false);
		getTitleBar().setMinimizeHeight(27);
		
		//component creation
		setSize(new IntDimension(103, 96));
		setPreferredSize(new IntDimension(103, 96));
		var layout0:FlowWrapLayout = new FlowWrapLayout();
		layout0.setPreferWidth(200);
		layout0.setAlignment(AsWingConstants.LEFT);
		layout0.setHgap(25);
		layout0.setVgap(3);
		layout0.setMargin(true);
		getContentPane().setLayout(layout0);
		
		btn_home_deliver = new JButton();
		btn_home_deliver.setLocation(new IntPoint(23, 0));
		btn_home_deliver.setSize(new IntDimension(57, 30));
		btn_home_deliver.setPreferredSize(new IntDimension(57, 30));
		btn_home_deliver.setText("label");
		
		btn_home_resist = new JButton();
		btn_home_resist.setLocation(new IntPoint(0, 0));
		btn_home_resist.setSize(new IntDimension(57, 30));
		btn_home_resist.setPreferredSize(new IntDimension(57, 30));
		btn_home_resist.setText("label");
		
		//component layoution
		getContentPane().append(btn_home_deliver);
		getContentPane().append(btn_home_resist);
		
		var img_char_background:DisplayObject = Client.getUIElement("img_home_invade_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		setSize(new IntDimension(img_char_background.width, img_char_background.height));
		setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - img_char_background.width) / 2,(Engine.H - img_char_background.height)/2);
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		btn_home_resist.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_home_resist.setText("反抗");
		btn_home_deliver.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_home_deliver.setText("解救");
		btn_home_deliver.addActionListener(onBtnDeliver);
		btn_home_resist.addActionListener(onBtnResist);
		btn_home_deliver.setBackground(ASColor.GRAY);
		btn_home_resist.setBackground(ASColor.GRAY);
		
	}
	
	private function onBtnDeliver(e:Event):void
	{
		FrameClickHomeCapture.hide();
		Client.getInstance().sendPacketLogic(1305,[int(Home.homeInfo.m_nCharId),int(_parent._building.buildingHomeId)]);
	}
	private function onBtnResist(e:Event):void
	{
		FrameClickHomeCapture.hide();
		Client.getInstance().sendPacketLogic(1306,[int(Home.homeInfo.m_nCharId),int(_parent._building.buildingHomeId)]);
	}
	public function update():void
	{
		btn_home_deliver.setEnabled(!Home.isInSelfHome());
		btn_home_resist.setEnabled(Home.isInSelfHome());
	}
	public static var _frame:FrameClickHomeCapture = null;
	public var _parent:PanelHomeCapture = null;
	public static var _item:Object = null;
	public static function show(parentHome:PanelHomeCapture,x:int,y:int):void
	{
		if(_frame == null)
		{
			_frame = new FrameClickHomeCapture();
			//parent.addChild(_frame);
		}
		_frame._parent = parentHome;
		parentHome.addChild(_frame);
		_frame.show();
		_frame.update();
		parentHome.bringToTop(_frame);
		
		_frame.setLocationXY(x, y);
		
	}
	public static function hide():void
	{
		if(isShowing())_frame.hide();
		_item = null;
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
	
}